home *** CD-ROM | disk | FTP | other *** search
/ Enter Special 3: Graphics & Video / Special_03.iso / Grafika / AutoImager 2.4 / setup_ai.exe / %MAINDIR% / Lib / gs_init.ps < prev    next >
Encoding:
Text File  |  2002-11-15  |  59.3 KB  |  1,846 lines

  1. %    Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of AFPL Ghostscript.
  3. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  4. % distributor accepts any responsibility for the consequences of using it, or
  5. % for whether it serves any particular purpose or works at all, unless he or
  6. % she says so in writing.  Refer to the Aladdin Free Public License (the
  7. % "License") for full details.
  8. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. % in a plain ASCII text file named PUBLIC.  The License grants you the right
  10. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. % conditions described in the License.  Among other things, the License
  12. % requires that the copyright notice and this notice be preserved on all
  13. % copies.
  14.  
  15. % $Id: gs_init.ps,v 1.40 2001/10/20 08:44:31 raph Exp $
  16. % Initialization file for the interpreter.
  17. % When this is run, systemdict is still writable.
  18.  
  19. % Comment lines of the form
  20. %    %% Replace <n> <file(s)>
  21. % indicate places where the next <n> lines should be replaced by
  22. % the contents of <file(s)>, when creating a single merged init file.
  23.  
  24. % The interpreter can call out to PostScript code.  All procedures
  25. % called in this way, and no other procedures defined in these
  26. % initialization files, have names that begin with %, e.g.,
  27. % (%Type1BuildChar) cvn.
  28.  
  29. % Check the interpreter revision.  NOTE: the interpreter code requires
  30. % that the first non-comment token in this file be an integer.
  31. 703
  32. dup revision ne
  33.  { (gs: Interpreter revision \() print revision 10 string cvs print
  34.    (\) does not match gs_init.ps revision \() print 10 string cvs print
  35.    (\).\n) print flush null 1 .quit
  36.  }
  37. if pop
  38.  
  39. % Acquire userdict, and set its length if necessary.
  40. /userdict where
  41.  { pop userdict maxlength 0 eq }
  42.  { true }
  43. ifelse
  44. systemdict exch
  45.  {        % userdict wasn't already set up by iinit.c.
  46.    dup /userdict
  47.    currentdict dup 200 .setmaxlength        % userdict
  48.    .forceput            % userdict is local, systemdict is global
  49.  }
  50. if begin
  51.  
  52. % Define dummy local/global operators if needed.
  53. systemdict /.setglobal known
  54.  { true .setglobal
  55.  }
  56.  { /.setglobal { pop } bind def
  57.    /.currentglobal { false } bind def
  58.    /.gcheck { pop false } bind def
  59.  }
  60. ifelse
  61.  
  62. % Define .languagelevel if needed.
  63. systemdict /.languagelevel known not { /.languagelevel 1 def } if
  64.  
  65. % Optionally choose a default paper size other than U.S. letter.
  66. % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
  67.  
  68. % Turn on array packing for the rest of initialization.
  69. true setpacking
  70.  
  71. % Define the old MS-DOS EOF character as a no-op.
  72. % This is a hack to get around the absurd habit of MS-DOS editors
  73. % of adding an EOF character at the end of the file.
  74. <1a> cvn { } def
  75.  
  76. % Acquire the debugging flags.
  77. currentdict /DEBUG known   /DEBUG exch def
  78.   /VMDEBUG
  79.     DEBUG {{print mark
  80.             systemdict /level2dict known
  81.          { .currentglobal dup false .setglobal vmstatus
  82.            true .setglobal vmstatus 3 -1 roll pop
  83.            6 -2 roll pop .setglobal
  84.          }
  85.          { vmstatus 3 -1 roll pop
  86.          }
  87.         ifelse usertime 16#fffff and counttomark
  88.           { ( ) print (           ) cvs print }
  89.         repeat pop
  90.         ( ) print systemdict length (    ) cvs print
  91.         ( ) print countdictstack (  ) cvs print
  92.         ( <) print count (    ) cvs print (>\n) print flush
  93.       }}
  94.       {{pop
  95.       }}
  96.      ifelse
  97.   def
  98.  
  99. currentdict /BATCH known   /BATCH exch def
  100. currentdict /DELAYBIND known   /DELAYBIND exch def
  101. currentdict /DISKFONTS known   /DISKFONTS exch def
  102. currentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } if
  103. currentdict /ESTACKPRINT known   /ESTACKPRINT exch def
  104. currentdict /FAKEFONTS known   /FAKEFONTS exch def
  105. currentdict /FIXEDMEDIA known   /FIXEDMEDIA exch def
  106. currentdict /FIXEDRESOLUTION known   /FIXEDRESOLUTION exch def
  107. currentdict /LOCALFONTS known   /LOCALFONTS exch def
  108. currentdict /NOBIND known   /NOBIND exch def
  109. /.bind /bind load def
  110. NOBIND { /bind { } def } if
  111. currentdict /NOCACHE known   /NOCACHE exch def
  112. currentdict /NOCCFONTS known   /NOCCFONTS exch def
  113. currentdict /NOCIE known   /NOCIE exch def
  114. currentdict /NODISPLAY known   not /DISPLAYING exch def
  115. currentdict /NOFONTMAP known   /NOFONTMAP exch def
  116. currentdict /NOFONTPATH known   /NOFONTPATH exch def
  117. currentdict /NOGC known   /NOGC exch def
  118. currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if
  119. currentdict /NOPAGEPROMPT known   /NOPAGEPROMPT exch def
  120. currentdict /NOPAUSE known   /NOPAUSE exch def
  121. currentdict /NOPLATFONTS known   /NOPLATFONTS exch def
  122. currentdict /NOPROMPT known   /NOPROMPT exch def
  123. % The default value of ORIENT1 is true, not false.
  124. currentdict /ORIENT1 known not { /ORIENT1 true def } if
  125. currentdict /OSTACKPRINT known   /OSTACKPRINT exch def
  126. currentdict /OUTPUTFILE known    % obsolete
  127.  { /OutputFile /OUTPUTFILE load def
  128.    currentdict /OUTPUTFILE .undef
  129.  } if
  130. currentdict /QUIET known   /QUIET exch def
  131. currentdict /SAFER known   /SAFER exch def
  132. currentdict /DELAYSAFER known   /DELAYSAFER exch def
  133. currentdict /SHORTERRORS known   /SHORTERRORS exch def
  134. currentdict /STRICT known   /STRICT exch def
  135. currentdict /TTYPAUSE known   /TTYPAUSE exch def
  136. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  137.  
  138. % Acquire environment variables.
  139. currentdict /DEVICE known not
  140.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  141.  
  142. (START) VMDEBUG
  143.  
  144. % Open the standard files, so they will be open at the outermost save level.
  145. (%stdin) (r) file pop
  146. (%stdout) (w) file pop
  147. (%stderr) (w) file pop
  148.  
  149. /.currentuserparams where {
  150.   pop mark
  151.     % The Adobe implementations appear to have very large maximum
  152.     % stack sizes.  This turns out to actually make a difference,
  153.     % since some badly-behaved files include extremely long procedures,
  154.     % or construct huge arrays on the operand stack.
  155.     % We reset the stack sizes now so that we don't have to worry
  156.     % about overflowing the (rather small) built-in stack sizes
  157.     % during initialization.
  158.   /MaxDictStack 500
  159.   /MaxExecStack 5000
  160.   /MaxOpStack 50000
  161.   .dicttomark .setuserparams
  162. } if
  163.  
  164. % Define a procedure for skipping over an unneeded section of code.
  165. % This avoids allocating space for the skipped procedures.
  166. % We can't use readline, because that imposes a line length limit.
  167. /.skipeof    % <string> .skipeof -
  168.  { currentfile exch 1 exch .subfiledecode flushfile
  169.  } .bind def
  170.  
  171. % Define procedures to assist users who don't read the documentation.
  172. userdict begin
  173. /help
  174.  { (Enter PostScript commands.  '(filename) run' runs a file, 'quit' exits.\n)
  175.    print flush
  176.  } .bind def
  177. end
  178.  
  179. % Define =string, which is used by some PostScript programs even though
  180. % it isn't documented anywhere.
  181. % Put it in userdict so that each context can have its own copy.
  182. userdict /=string 256 string put
  183.  
  184. % Print the greeting.
  185.  
  186. /printgreeting
  187.  { mark
  188.    product (Ghostscript) search
  189.     { pop pop pop
  190.       (This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
  191.     }
  192.     { pop
  193.     }
  194.    ifelse
  195.    (\n) copyright
  196.    (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-)
  197.    revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-)
  198.    revisiondate 10000 idiv ( \()
  199.    revision 10 mod
  200.    revision 100 mod 10 idiv (.)
  201.    revision 100 idiv ( )
  202.    product
  203.    counttomark
  204.     { (%stdout) (w) file exch 0 .writecvp
  205.     } repeat pop
  206.  } .bind def
  207.  
  208. QUIET not { printgreeting flush } if
  209.  
  210. % Define a special version of def for making operator procedures.
  211. /obind {    % <name> <proc> obind <name> <oper>
  212.   1 index exch .makeoperator
  213. } .bind def
  214. /odef {        % <name> <proc> odef -
  215.   1 index exch .makeoperator def
  216. } .bind def
  217.  
  218. % Define a special version of def for storing local objects into global
  219. % dictionaries.  Like .forceput, this exists only during initialization.
  220. /.forcedef {        % <key> <value> .forcedef -
  221.   currentdict 3 1 roll .forceput
  222. } .bind odef
  223.  
  224. % Define procedures for accessing variables in systemdict and userdict
  225. % regardless of the contents of the dictionary stack.
  226. /.systemvar {        % <name> .systemvar <value>
  227.   //systemdict exch get
  228. } .bind odef
  229. /.userdict {        % - .userdict <dict>
  230.   /userdict .systemvar
  231. } .bind odef
  232. /.uservar {        % <name> .uservar <value>
  233.   .userdict exch get
  234. } .bind odef
  235.  
  236. % If we're delaying binding, remember everything that needs to be bound later.
  237. DELAYBIND NOBIND not and
  238.  { .currentglobal false .setglobal
  239.    systemdict /.delaybind 1500 array .forceput
  240.    .setglobal
  241.    userdict /.delaycount 0 put
  242.     % When we've done the delayed bind, we want to stop saving.
  243.     % Detect this by the disappearance of .delaybind.
  244.    /bind
  245.     { /.delaybind .systemvar dup length 0 ne
  246.        { .delaycount 2 index put
  247.          .userdict /.delaycount .delaycount 1 add put
  248.        }
  249.        { pop .bind
  250.        }
  251.       ifelse
  252.     } .bind def
  253.  } if
  254.  
  255. %**************** BACKWARD COMPATIBILITY
  256. /hwsizedict mark /HWSize null .dicttomark readonly def
  257. /copyscanlines {        % <device> <y> <string> copyscanlines <substr>
  258.   0 3 1 roll 3 index //hwsizedict .getdeviceparams
  259.   exch pop exch pop aload pop 3 2 roll
  260.   0 exch null exch .getbitsrect exch pop
  261. } bind odef
  262. currentdict /hwsizedict .undef
  263. /getdeviceprops
  264.  { null .getdeviceparams
  265.  } bind odef
  266. /.putdeviceprops
  267.  { null true counttomark 1 add 3 roll .putdeviceparams
  268.    dup type /booleantype ne
  269.     { dup mark eq { /unknown /rangecheck } if
  270.       counttomark 4 add 1 roll cleartomark pop pop pop
  271.       /.putdeviceprops load exch signalerror
  272.     }
  273.    if
  274.  } bind odef
  275. /max { .max } bind def
  276. /min { .min } bind def
  277. /.currentfilladjust { .currentfilladjust2 pop } bind odef
  278. /.setfilladjust { dup .setfilladjust2 } bind odef
  279. /unread /.unread load def
  280. /.writecvs { 0 .writecvp } bind odef
  281.  
  282. % Define predefined procedures substituting for operators,
  283. % in alphabetical order.
  284.  
  285. userdict /#copies 1 put
  286. % Adobe implementations don't accept /[ or /], so we don't either.
  287. ([) cvn
  288.     /mark load def
  289. (]) cvn
  290.     {counttomark array astore exch pop} odef
  291. % .beginpage is redefined if setpagedevice is present.
  292. /.beginpage { } odef
  293. % In LanguageLevel 3, copypage erases the page.
  294. /copypage {
  295.     .languagelevel 3 ge
  296.     dup { 0 } { 1 } ifelse .endpage {
  297.       .currentnumcopies 1 index .outputpage
  298.       (>>copypage, press <return> to continue<<\n) .confirm
  299.       dup { erasepage } if
  300.     } if pop .beginpage
  301. } odef
  302. /currentmatrix {
  303.     .currentmatrix 6 index astore pop
  304. } odef
  305. % .currentnumcopies is redefined in Level 2.
  306. /.currentnumcopies { #copies } odef
  307. /setcolorscreen where { pop        % not in all Level 1 configurations
  308.    /currentcolorscreen
  309.     { .currenthalftone
  310.        { { 60 exch 0 exch 3 copy 6 copy }    % halftone - not possible
  311.          { 3 copy 6 copy }            % screen
  312.          { }                % colorscreen
  313.        }
  314.       exch get exec
  315.     } odef
  316. } if
  317. /currentscreen
  318.     { .currenthalftone
  319.        { { 60 exch 0 exch }            % halftone - not possible
  320.          { }                % screen
  321.          { 12 3 roll 9 { pop } repeat }    % colorscreen
  322.        }
  323.       exch get exec
  324.     } odef
  325. /.echo /echo load def
  326. userdict /.echo.mode true put
  327. /echo    {dup /.echo.mode exch store .echo} odef
  328. /eexec {
  329.     % Rebind .currentresourcefile if it is the source for the eexec.
  330.   dup 55665 //filterdict /eexecDecode get exec
  331.   cvx exch .currentresourcefile eq
  332.   //systemdict begin { {exec} .execasresource } { exec } ifelse
  333.     % Only pop systemdict if it is still the top element,
  334.     % because this is apparently what Adobe interpreters do.
  335.   currentdict //systemdict eq { end } if
  336. } odef
  337. % .endpage is redefined if setpagedevice is present.
  338. /.endpage { 2 ne } odef
  339. % erasepage mustn't use gsave/grestore, because we call it before
  340. % the graphics state stack has been fully initialized.
  341. /erasepage
  342.     { /currentcolor where
  343.        { pop currentcolor currentcolorspace { setcolorspace setcolor } }
  344.        { /currentcmykcolor where
  345.           { pop currentcmykcolor { setcmykcolor } }
  346.           { currentrgbcolor { setrgbcolor } }
  347.          ifelse
  348.        }
  349.       ifelse 1 setgray .fillpage exec
  350.     } odef
  351. % To satisfy the Genoa FTS, executive must be a procedure, not an operator.
  352. /executive
  353.     { { prompt
  354.          { (%statementedit) (r) file } stopped
  355.          { pop pop $error /errorname get /undefinedfilename eq
  356.         { .clearerror exit } if        % EOF
  357.            handleerror null        % ioerror??
  358.          }
  359.         if
  360.         cvx { .runexec } execute
  361.       } loop
  362.     } bind def
  363. /filter
  364.     { //filterdict 1 index .knownget
  365.        { exch pop exec }
  366.        { /filter load /undefined signalerror }
  367.       ifelse
  368.     } odef
  369. /handleerror
  370.     { /errordict .systemvar /handleerror get exec } bind def
  371. /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
  372. /identmatrix
  373.     { dup 0 //identmatrix putinterval } odef
  374. /languagelevel 1 def        % gs_lev2.ps may change this
  375. /makeimagedevice { false makewordimagedevice } odef
  376. /matrix    { 6 array identmatrix } odef
  377. /pathbbox
  378.     { false .pathbbox
  379.     } odef
  380. % .promptmsg is redefined if the interpreter includes readline support.
  381. /.promptmsg {
  382.     (GS) print
  383.     count 0 ne { (<) print count =only } if
  384.     (>) print flush
  385. } bind def
  386. /prompt    { flush flushpage NOPROMPT not { .promptmsg } if } bind def
  387. /pstack    { 0 1 count 3 sub { index == } for } bind def
  388. /putdeviceprops
  389.     { .putdeviceprops { erasepage } if } odef
  390. /quit    { /quit load 0 .quit } odef
  391. /run    { dup type /filetype ne { (r) file } if
  392.         % We must close the file when execution terminates,
  393.         % regardless of the state of the stack,
  394.         % and then propagate an error, if any.
  395.       cvx .runexec
  396.     } odef
  397. % Execute a file.
  398. % Level 2 uses 2 .stop to clear the e-stack for a successful startjob:
  399. % we detect that here, since we need to handle this even if we start out
  400. % without job control in effect.
  401. %
  402. % What we push on the e-stack is the following to be executed in this order:
  403. %    <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2
  404. /.runexec1 {        % <file|fileproc> .runexec1 -
  405.   dup type /filetype ne { cvx exec } if
  406.   cvx null 2 .stopped
  407.     % If we got back here from a startjob, just keep going.
  408.     % startjob replaces the null on the o-stack with a procedure
  409.     % to be executed when we get back here.
  410.   dup null ne { exec true } { pop false } ifelse
  411. } bind def
  412. /.runexec2 {        % <continue> <file|fileproc> .runexec2 -
  413.   exch {
  414.     .runexec
  415.   } {
  416.     dup type /filetype ne { cvx exec } if
  417.     closefile
  418.   } ifelse
  419. } bind def
  420. /.runexec {        % <file|fileproc> .runexec -
  421.   cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn
  422. } bind def
  423. % The following is only for compatibility with Adobe interpreters.
  424. /setdash {
  425.     1 index length 11 gt { /setdash load /limitcheck signalerror } if
  426.     //setdash
  427. } odef
  428. /setdevice
  429.     { .setdevice { erasepage } if } odef
  430. /setlinecap {
  431.     dup 2 gt { /setlinecap load /rangecheck signalerror } if
  432.     .setlinecap
  433. } odef
  434. /setlinejoin {
  435.     dup 2 gt { /setlinejoin load /rangecheck signalerror } if
  436.     .setlinejoin
  437. } odef
  438. /setmatrix {
  439.     dup aload pop .setmatrix pop
  440. } odef
  441. /showpage {
  442.     0 .endpage .doneshowpage {
  443.       .currentnumcopies true .outputpage
  444.       (>>showpage, press <return> to continue<<\n) .confirm
  445.       erasepage
  446.     } if initgraphics .beginpage
  447. } odef
  448. % Code output by Adobe Illustrator relies on the fact that
  449. % `stack' is a procedure, not an operator!!!
  450. /stack    { 0 1 count 3 sub { index = } for } bind def
  451. /start    { BATCH { null 0 .quit } { executive } ifelse } def
  452. % Internal uses of stopped that aren't going to do a stop if an error occurs
  453. % should use .internalstopped to avoid setting newerror et al.
  454. /.internalstopped { null 1 .stopped null ne } bind def
  455. /store {    % Don't alter operands before completing.
  456.     1 index where { 2 index 2 index put pop pop } { def } ifelse
  457. } odef
  458. /.typenames mark .typenames counttomark packedarray exch pop def
  459. /type {
  460.     //.typenames .type
  461. } odef
  462. currentdict /.typenames .undef
  463. % When running in Level 1 mode, this interpreter is supposed to be
  464. % compatible with PostScript "version" 54.0 (I think).
  465. /version (54.0) readonly def
  466. /.wheredict 10 dict def
  467. /.where /where load def
  468. /where {
  469.     //.wheredict 1 index .knownget { exec } { .where } ifelse
  470. } odef
  471.  
  472. % internaldict is defined in systemdict, but the dictionary is allocated
  473. % in local VM.  However, the procedure must be global, since it is an
  474. % "operator" and must be bind-able into global procedures.
  475. % We make a procedure for creating it, since we must create a new one
  476. % for each context with private local VM.
  477. /.makeinternaldict {
  478.   .currentglobal true .setglobal
  479.     [ /dup .systemvar 1183615869 /eq .systemvar
  480.     [ /pop .systemvar null ] cvx
  481.     false .setglobal
  482.     dup 1 10 dict .forceput    % proc is global, dict is local
  483.     true .setglobal
  484.     [ /internaldict /cvx .systemvar /invalidaccess /signalerror cvx ] cvx
  485.       /ifelse .systemvar
  486.     ] cvx executeonly
  487.   exch .setglobal
  488. } odef
  489. systemdict /internaldict dup .makeinternaldict .makeoperator
  490. .forceput        % proc is local, systemdict is global
  491. % Move superexec to internaldict if superexec is defined.
  492. currentdict /superexec .knownget {
  493.   1183615869 internaldict /superexec 3 -1 roll put
  494.   currentdict /superexec .undef
  495. } if
  496.  
  497. % Define some additional built-in procedures (beyond the ones defined by
  498. % the PostScript Language Reference Manual).
  499. % Warning: these are not guaranteed to stay the same from one release
  500. % to the next!
  501. /concatstrings
  502.     { exch dup length 2 index length add string    % str2 str1 new
  503.       dup dup 4 2 roll copy        % str2 new new new1
  504.       length 4 -1 roll putinterval
  505.     } bind def
  506. /copyarray
  507.     { dup length array copy } bind def
  508. % Copy a dictionary per the Level 2 spec even in Level 1.
  509. /.copydict        % <fromdict> <todict> .copydict <todict>
  510.     { dup 3 -1 roll { put dup } forall pop } bind def
  511. /copystring
  512.     { dup length string copy } bind def
  513. /findlibfile {
  514.     .libfile { dup .filename pop exch true } { false } ifelse
  515. } odef
  516. /.growdictlength    % get size for growing a dictionary
  517.     { length 3 mul 2 idiv 1 add
  518.     } bind def
  519. /.growdict        % grow a dictionary
  520.     { dup .growdictlength .setmaxlength
  521.     } bind def
  522. /.growput        % put, grow the dictionary if needed
  523.     { 2 index length 3 index maxlength eq
  524.        { 3 copy pop known not { 2 index .growdict } if
  525.        } if
  526.       put
  527.     } bind def
  528. % .localvmarray may be an operator: see zsysvm.c.
  529. /.localvmarray where {
  530.   pop
  531. } {
  532.   /.localvmarray {
  533.     .currentglobal false .setglobal
  534.     exch array exch .setglobal
  535.   } bind def
  536. } ifelse
  537. /.localvmdict where {
  538.   pop
  539. } {
  540.   /.localvmdict {
  541.     .currentglobal false .setglobal
  542.     exch dict exch .setglobal
  543.   } bind def
  544. } ifelse
  545. /.packtomark
  546.     { counttomark packedarray exch pop } bind def
  547. /ppstack
  548.     { 0 1 count 3 sub { index === } for } bind def
  549. /runlibfile
  550.     {        % We don't want to bind 'run' into this procedure,
  551.             % since run may get redefined.
  552.       findlibfile
  553.        { exch pop /run .systemvar exec }
  554.        { /undefinedfilename signalerror }
  555.       ifelse
  556.     } bind def
  557. /selectdevice
  558.     { finddevice setdevice .setdefaultscreen } bind def
  559. /signalerror        % <object> <errorname> signalerror -
  560.     { /errordict .systemvar exch get exec } bind def
  561.  
  562. % Define the =[only] procedures.  Also define =print,
  563. % which is used by some PostScript programs even though
  564. % it isn't documented anywhere.
  565. /write=only {
  566.     .writecvs
  567. } bind def
  568. /write= {
  569.     1 index exch write=only (\n) writestring
  570. } bind def
  571. /=only    { (%stdout) (w) file exch write=only } bind def
  572. /=    { =only (\n) print } bind def
  573. /=print    /=only load def
  574. % Temporarily define == as = for the sake of runlibfile0.
  575. /== /= load def
  576.  
  577. % The following procedures are documented.
  578. /copydevice {        % <device> copydevice <newdevice>
  579.   false .copydevice2
  580. } odef
  581. /finddevice {        % <devicename> finddevice <device>
  582.   /devicedict .systemvar exch get
  583.   dup 1 get null eq {
  584.         % This is the first request for this type of device.
  585.         % Create a default instance now.
  586.         % Stack: [proto null]
  587.     .currentglobal true .setglobal exch
  588.     dup dup 0 get copydevice 1 exch put
  589.     exch .setglobal
  590.   } if 1 get
  591. } bind def
  592. /findprotodevice {    % <devicename> findprotodevice <protodevice>
  593.   /devicedict .systemvar exch get 0 get
  594. } bind def
  595.  
  596. % Run a resource file.  This allows us to distinguish resource objects
  597. % from objects coming from input files.
  598. userdict /.currentresourcefile null put
  599. /.execasresource {    % <file> <proc|runfile> .execasresource -
  600.   /stopped .systemvar
  601.   /.currentresourcefile .uservar
  602.         % Stack: file proc -stopped- currfile
  603.   .userdict /.currentresourcefile 5 index cvlit put
  604.   2 .execn        % stopped <file>
  605.   .userdict /.currentresourcefile 3 -1 roll put
  606.   { stop } if
  607. } bind def
  608. /.runresource {        % <file> .runresource -
  609.   { /run .systemvar exec } .execasresource
  610. } bind def
  611.  
  612. % Define procedures for getting and setting the current device resolution.
  613.  
  614. /gsgetdeviceprop    % <device> <propname> gsgetdeviceprop <value>
  615.  { 2 copy mark exch null .dicttomark .getdeviceparams
  616.    dup mark eq        % if true, not found
  617.     { pop dup /undefined signalerror }
  618.     { 5 1 roll pop pop pop pop }
  619.    ifelse
  620.  } bind def
  621. /gscurrentresolution    % - gscurrentresolution <[xres yres]>
  622.  { currentdevice /HWResolution gsgetdeviceprop
  623.  } bind def
  624. /gssetresolution    % <[xres yres]> gssetresolution -
  625.  { 2 array astore mark exch /HWResolution exch
  626.    currentdevice copydevice putdeviceprops setdevice
  627.  } bind def
  628.  
  629. % Define auxiliary procedures needed for the above.
  630. /shellarguments        % -> shell_arguments true (or) false
  631.     { /ARGUMENTS where
  632.        { /ARGUMENTS get dup type /arraytype eq
  633.           { aload pop /ARGUMENTS null store true }
  634.           { pop false }
  635.          ifelse }
  636.        { false } ifelse
  637.     } bind def
  638. /.confirm {
  639.   DISPLAYING NOPAUSE not TTYPAUSE or and {
  640.     % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
  641.     % and wait for the user to type something.
  642.     % If the user just types a newline, flush it.
  643.     NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
  644.     .confirmread
  645.   } {
  646.     pop
  647.   } ifelse
  648. } bind def
  649. /.confirmread {
  650.   TTYPAUSE {
  651.     (/dev/tty) (r) file dup read pop pop closefile
  652.   } {
  653.     .echo.mode false echo
  654.     (%stdin) (r) file dup read {
  655.       dup (\n) 0 get eq { pop pop } { unread } ifelse
  656.     } {
  657.       pop
  658.     } ifelse echo
  659.   } ifelse
  660. } bind def
  661.  
  662. % Define the procedure used by .runfile, .runstdin and .runstring
  663. % for executing user input.
  664. % This is called with a procedure or executable file on the operand stack.
  665. /.execute {        % <obj> .execute <stopped>
  666.   stopped $error /newerror get and
  667.    { handleerror flush true } { false } ifelse
  668. } bind def
  669. /execute {        % <obj> execute -
  670.   .execute pop
  671. } odef
  672. % Define an execute analogue of runlibfile0.
  673. /execute0 {        % <obj> execute0 -
  674.   .execute { /execute0 cvx 1 .quit } if
  675. } bind def
  676. % Define the procedure that the C code uses for running files
  677. % named on the command line.
  678. /.runfile {
  679.   { runlibfile } execute0
  680. } def
  681. % Define the procedure that the C code uses for running piped input.
  682. % We don't use the obvious { (%stdin) run }, because we want the file to be
  683. % reopened if a startjob does a restore.
  684. /.runstdin {
  685.   { { (%stdin) (r) file cvx } .runexec } execute0
  686. } bind def
  687. % Define the procedure that the C code uses for running commands
  688. % given on the command line with -c.  We turn the string into a file so that
  689. % .runexec can do the right thing with a startjob.
  690. /.runstring {
  691.   .currentglobal exch true .setglobal
  692.   0 () .subfiledecode
  693.   exch .setglobal cvx { .runexec } execute0
  694. } bind def
  695. % Define the procedure that the C code uses to set up for executing
  696. % a string that may be received in pieces.
  697. /.runstringbegin {
  698.   .currentglobal true .setglobal
  699.   { .needinput } bind 0 () .subfiledecode
  700.   exch .setglobal cvx .runexec
  701. } bind def
  702.  
  703. % Define a special version of runlibfile that aborts on errors.
  704. /runlibfile0
  705.     { cvlit dup /.currentfilename exch def
  706.        { findlibfile not { stop } if }
  707.       stopped
  708.        { (Can't find \(or open\) initialization file ) print
  709.          .currentfilename == flush /runlibfile0 cvx 1 .quit
  710.        } if
  711.       exch pop cvx stopped
  712.        { (While reading ) print .currentfilename print (:\n) print flush
  713.          handleerror /runlibfile0 1 .quit
  714.        } if
  715.     } bind def
  716. % Temporarily substitute it for the real runlibfile.
  717. /.runlibfile /runlibfile load def
  718. /runlibfile /runlibfile0 load def
  719.  
  720. % Create the error handling machinery.
  721. % Define the standard error handlers.
  722. % The interpreter has created the ErrorNames array.
  723. /.unstoppederrorhandler    % <command> <errorname> .unstoppederrorhandler -
  724.  {    % This is the handler that gets used for recursive errors,
  725.     % or errors outside the scope of a 'stopped'.
  726.    2 copy SHORTERRORS
  727.     { (%%[ Error: ) print =only flush
  728.       (; OffendingCommand: ) print =only ( ]%%) =
  729.     }
  730.     { (Unrecoverable error: ) print =only flush
  731.       ( in ) print = flush
  732.       count 2 gt
  733.        { (Operand stack:\n  ) print
  734.      2 1 count 3 sub { (  ) print index =only flush } for
  735.      () = flush
  736.        } if
  737.     }
  738.    ifelse
  739.    -1 0 1 //ErrorNames length 1 sub
  740.     { dup //ErrorNames exch get 3 index eq
  741.        { not exch pop exit } { pop } ifelse
  742.     }
  743.    for exch pop .quit
  744.  } bind def
  745. /.errorhandler        % <command> <errorname> .errorhandler -
  746.   {        % Detect an internal 'stopped'.
  747.     1 .instopped { null eq { pop pop stop } if } if
  748.     $error /.inerror get 1 .instopped { pop } { pop true } ifelse
  749.      { .unstoppederrorhandler
  750.      } if    % detect error recursion
  751.     $error /globalmode .currentglobal false .setglobal put
  752.     $error /.inerror true put
  753.     $error /newerror true put
  754.     $error exch /errorname exch put
  755.     $error exch /command exch put
  756.     $error /recordstacks get $error /errorname get /VMerror ne and
  757.      {        % Attempt to store the stack contents atomically.
  758.        count array astore dup $error /ostack 4 -1 roll
  759.        countexecstack array execstack $error /estack 3 -1 roll
  760.        countdictstack array dictstack $error /dstack 3 -1 roll
  761.        put put put aload pop
  762.      }
  763.      { $error /dstack .undef
  764.        $error /estack .undef
  765.        $error /ostack .undef
  766.      }
  767.     ifelse
  768.     $error /position currentfile status
  769.      { currentfile { fileposition } .internalstopped { pop null } if
  770.      }
  771.      {        % If this was a scanner error, the file is no longer current,
  772.         % but the command holds the file, which may still be open.
  773.        $error /command get dup type /filetype eq
  774.         { { fileposition } .internalstopped { pop null } if }
  775.         { pop null }
  776.        ifelse
  777.      }
  778.     ifelse put
  779.         % During initialization, we don't reset the allocation
  780.         % mode on errors.
  781.     $error /globalmode get $error /.nosetlocal get and .setglobal
  782.     $error /.inerror false put
  783.     stop
  784.   } bind def
  785. % Define the standard handleerror.  We break out the printing procedure
  786. % (.printerror) so that it can be extended for binary output
  787. % if the Level 2 facilities are present.
  788.   /.printerror
  789.    { $error begin
  790.        /command load errorname SHORTERRORS
  791.     { (%%[ Error: ) print =only flush
  792.       (; OffendingCommand: ) print =only
  793.       errorinfo dup null eq {
  794.         pop
  795.       } {
  796.         (;\nErrorInfo:) print
  797.         dup type /arraytype eq
  798.           { { ( ) print =only } forall }
  799.           { ( ) print =only }
  800.         ifelse
  801.       } ifelse
  802.           ( ]%%) = flush
  803.     }
  804.     { (Error: ) print ==only flush
  805.       ( in ) print ==only flush
  806.       errorinfo dup null eq {
  807.         pop
  808.       } {
  809.         (\nAdditional information: ) print ==only flush
  810.       } ifelse
  811.       .printerror_long
  812.     }
  813.        ifelse
  814.        .clearerror
  815.      end
  816.      flush
  817.     } bind def     
  818.   /.printerror_long            % long error printout,
  819.                     % $error is on the dict stack
  820.    {    % Push the (anonymous) stack printing procedure.
  821.     %  <heading> <==flag> <override-name> <stackname> proc
  822.        {
  823.      currentdict exch .knownget    % stackname defined in $error?
  824.      {
  825.        4 1 roll            % stack: <stack> <head> <==flag> <over>
  826.        errordict exch .knownget    % overridename defined?
  827.        { 
  828.          exch pop exch pop exec    % call override with <stack>
  829.        }
  830.        { 
  831.          exch print exch        % print heading. stack <==flag> <stack>
  832.          1 index not { () = } if
  833.          { 1 index { (\n    ) } { (   ) } ifelse print
  834.            dup type /dicttype eq
  835.            {
  836.          (--dict:) print
  837.          dup rcheck {
  838.            dup length =only (/) print dup maxlength =only
  839.            dup wcheck not { ((ro)) print } if
  840.          } if
  841.          /gcheck where {
  842.            pop gcheck { ((G)) } { ((L)) } ifelse print
  843.          } {
  844.            pop
  845.          } ifelse (--) print
  846.            }
  847.            {
  848.          dup type /stringtype eq 2 index or
  849.          { ==only } { =only } ifelse
  850.            } ifelse
  851.          } forall
  852.          pop
  853.        }
  854.        ifelse            % overridden
  855.      }
  856.      { pop pop pop
  857.      }
  858.      ifelse                % stack known
  859.        }
  860.  
  861.        (\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec
  862.        (\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec
  863.        (\nBacktrace:) true /.printbacktrace /backtrace 4 index exec
  864.        (\nDictionary stack:) false /.printdstack /dstack 4 index exec
  865.        () =
  866.        pop    % printing procedure
  867.  
  868.        errorname /VMerror eq
  869.     { (VM status:) print mark vmstatus
  870.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  871.       cleartomark () =
  872.     } if
  873.  
  874.        .languagelevel 2 ge
  875.     { (Current allocation mode is ) print
  876.       globalmode { (global\n) } { (local\n) } ifelse print
  877.     } if
  878.  
  879.        .oserrno dup 0 ne
  880.     { (Last OS error: ) print
  881.       errorname /VMerror ne
  882.        { dup .oserrorstring { = pop } { = } ifelse }
  883.        { = }
  884.       ifelse
  885.     }
  886.     { pop
  887.     }
  888.        ifelse
  889.  
  890.        position null ne
  891.     { (Current file position is ) print position = }
  892.        if
  893.  
  894.    } bind def
  895. % Define a procedure for clearing the error indication.
  896. /.clearerror
  897.  { $error /newerror false put
  898.    $error /errorname null put
  899.    $error /errorinfo null put
  900.    0 .setoserrno
  901.  } bind def
  902.  
  903. % Define $error.  This must be in local VM.
  904. .currentglobal false .setglobal
  905. /$error 40 dict .forcedef    % $error is local, systemdict is global
  906.         % newerror, errorname, command, errorinfo,
  907.         % ostack, estack, dstack, recordstacks,
  908.         % binary, globalmode,
  909.         % .inerror, .nosetlocal, position,
  910.         % plus extra space for badly designed error handers.
  911. $error begin
  912.   /newerror false def
  913.   /recordstacks true def
  914.   /binary false def
  915.   /globalmode .currentglobal def
  916.   /.inerror false def
  917.   /.nosetlocal true def
  918.   /position null def
  919. end
  920. % Define errordict similarly.  It has one entry per error name,
  921. %   plus handleerror.  However, some astonishingly badly written PostScript
  922. %   files require it to have at least one empty slot.
  923. /errordict ErrorNames length 2 add dict
  924. .forcedef        % errordict is local, systemdict is global
  925. .setglobal        % contents of errordict are global
  926. errordict begin
  927.   ErrorNames
  928.    { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
  929.    } forall
  930. % The handlers for interrupt and timeout are special; there is no
  931. % 'current object', so they push their own name.
  932.    { /interrupt /timeout }
  933.    { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
  934.    } forall
  935. /handleerror
  936.  { /.printerror .systemvar exec
  937.  } bind def
  938. end
  939.  
  940. % Define the [write]==[only] procedures.
  941. /.dict 8 dict dup
  942. begin def
  943.   /.cvp {1 index exch 1 .writecvp} bind def
  944.   /.p {1 index exch writestring} bind def
  945.   /.p1 {2 index exch writestring} bind def
  946.   /.p2 {3 index exch writestring} bind def
  947.   /.print
  948.     { dup type .dict exch .knownget { exec } { .cvp } ifelse
  949.     } bind def
  950.   /arraytype
  951.     {dup rcheck
  952.       {() exch dup xcheck
  953.         {({) .p2
  954.          {exch .p1
  955.           1 index exch .print pop ( )} forall
  956.          (})}
  957.         {([) .p2
  958.          {exch .p1
  959.           1 index exch .print pop ( )} forall
  960.          (])}
  961.        ifelse exch pop .p}
  962.       {.cvp}
  963.      ifelse} bind def
  964.   /packedarraytype /arraytype load def
  965. {//.dict begin .print pop end}
  966.   bind
  967. end
  968.  
  969. /write==only exch def
  970. /write== {1 index exch write==only (\n) writestring} bind def
  971. /==only { (%stdout) (w) file exch write==only } bind def
  972. /== {==only (\n) print} bind def
  973.  
  974. % Define [write]===[only], an extension that prints dictionaries
  975. % in readable form and doesn't truncate strings.
  976. /.dict /write==only load 0 get dup length 2 add dict .copydict dup
  977. begin def
  978.   /dicttype
  979.     { dup rcheck
  980.        { (<< ) .p1
  981.           { 2 index 3 -1 roll .print pop ( ) .p1
  982.         1 index exch .print pop ( ) .p
  983.           }
  984.          forall (>>) .p
  985.        }
  986.        { .cvp
  987.        }
  988.       ifelse
  989.     } bind def
  990.   /stringtype
  991.     { 1 index exch 2 .writecvp
  992.     } bind def
  993.  
  994. {//.dict begin .print pop end}
  995.   bind
  996. end
  997.  
  998. /write===only exch def
  999. /write=== {1 index exch write===only (\n) writestring} bind def
  1000. /===only { (%stdout) (w) file exch write===only } bind def
  1001. /=== { ===only (\n) print } bind def
  1002.  
  1003. (END PROCS) VMDEBUG
  1004.  
  1005. % Define the font directory.
  1006. /FontDirectory false .setglobal 100 dict true .setglobal
  1007. .forcedef        % FontDirectory is local, systemdict is global
  1008.  
  1009. % Define the encoding dictionary.
  1010. /EncodingDirectory 16 dict def    % enough for Level 2 + PDF standard encodings
  1011.  
  1012. % Define .findencoding.  (This is redefined in Level 2.)
  1013. /.findencoding
  1014.  { //EncodingDirectory exch get exec
  1015.  } bind def
  1016. /.defineencoding
  1017.  { //EncodingDirectory 3 1 roll put
  1018.  } bind def
  1019. % If we've got the composite font extensions, define findencoding.
  1020. % To satisfy the Genoa FTS, findencoding must be a procedure, not an operator.
  1021. /rootfont where { pop /findencoding { .findencoding } def } if
  1022.  
  1023. % Define .registerencoding.
  1024. % NOTE: the name registeredencodings is known to (initialized by and shared
  1025. % with) the interpreter.
  1026. /.registerencoding {    % <index> <array> .registerencoding -
  1027.     % Check that the array is indexable.
  1028.     % (It might still be a string, but then the .namestring will fail.)
  1029.   dup 0 0 getinterval pop
  1030.     % Check that all the elements of the array are names.
  1031.   dup { .namestring pop } forall
  1032.     % Do the store.
  1033.   //registeredencodings 2 index 2 index readonly put pop pop
  1034. } bind odef
  1035. systemdict /registeredencodings .undef
  1036.  
  1037. % Load StandardEncoding.
  1038. %% Replace 1 (gs_std_e.ps)
  1039. (gs_std_e.ps) dup runlibfile VMDEBUG
  1040.  
  1041. % Load ISOLatin1Encoding.
  1042. %% Replace 1 (gs_il1_e.ps)
  1043. (gs_il1_e.ps) dup runlibfile VMDEBUG
  1044.  
  1045. % Define stubs for the Symbol and Dingbats encodings.
  1046. % Note that the first element of the procedure must be the file name,
  1047. % since gs_lev2.ps extracts it to set up the Encoding resource category.
  1048.  
  1049.   /SymbolEncoding { /SymbolEncoding .findencoding } bind def
  1050. %% Replace 3 (gs_sym_e.ps)
  1051.   EncodingDirectory /SymbolEncoding
  1052.    { (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end }
  1053.   bind put
  1054.  
  1055.   /DingbatsEncoding { /DingbatsEncoding .findencoding } bind def
  1056. %% Replace 3 (gs_dbt_e.ps)
  1057.   EncodingDirectory /DingbatsEncoding
  1058.    { (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end }
  1059.   bind put
  1060.  
  1061. (END FONTDIR/ENCS) VMDEBUG
  1062.  
  1063. % Construct a dictionary of all available devices.
  1064. % These are (read-only) device prototypes that can't be
  1065. % installed or have their parameters changed.  For this reason,
  1066. % the value in the dictionary is actually a 2-element writable array,
  1067. % to allow us to create a default instance of the prototype on demand.
  1068.  
  1069.     % Loop until the .getdevice gets a rangecheck.
  1070. errordict /rangecheck 2 copy get
  1071. errordict /rangecheck { pop stop } put    % pop the command
  1072.   0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
  1073.   1 add dict  /devicedict 1 index def
  1074.   begin            % 2nd copy of count is on stack
  1075.    { dup .devicename exch
  1076.      dup wcheck { dup } { null } ifelse 2 array astore def
  1077.    } repeat
  1078.   end
  1079. put        % errordict /rangecheck
  1080. .clearerror
  1081. /devicenames devicedict { pop } forall devicedict length packedarray def
  1082.  
  1083. % Determine the default device.
  1084. /defaultdevice DISPLAYING
  1085.  { systemdict /DEVICE .knownget
  1086.     { devicedict 1 index known not
  1087.        { (Unknown device: ) print =
  1088.      flush /defaultdevice cvx 1 .quit
  1089.        }
  1090.       if
  1091.     }
  1092.     { 0 .getdevice .devicename
  1093.     }
  1094.    ifelse
  1095.  }
  1096.  { /nullpage
  1097.  }
  1098. ifelse
  1099. /.defaultdevicename 1 index def
  1100. finddevice    % make a copy
  1101. def
  1102. devicedict /Default devicedict .defaultdevicename get put
  1103.  
  1104. (END DEVS) VMDEBUG
  1105.  
  1106. % Define statusdict, for the benefit of programs
  1107. % that think they are running on a LaserWriter or similar printer.
  1108. %% Replace 1 (gs_statd.ps)
  1109. (gs_statd.ps) runlibfile
  1110.  
  1111. (END STATD) VMDEBUG
  1112.  
  1113. % Load the standard font environment.
  1114. %% Replace 1 (gs_fonts.ps)
  1115. (gs_fonts.ps) runlibfile
  1116.  
  1117. (END GS_FONTS) VMDEBUG
  1118.  
  1119. % Define the default halftone screen and BG/UCR functions now, so that
  1120. % it will bind in the original definitions of set[color]screen.
  1121. % We make this a procedure so we can call it again when switching devices.
  1122.  
  1123. % Use an ordered dither for low-resolution devices.
  1124. /.setloreshalftone {    % <dpi> .setloreshalftone -
  1125.     % The following 'ordered dither' spot function was contributed by
  1126.     % Gregg Townsend.  Thanks, Gregg!
  1127.    16.001 div 0            % not 16: avoids rounding problems
  1128.     { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  1129.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  1130.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  1131.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  1132.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  1133.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  1134.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  1135.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  1136.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  1137.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  1138.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  1139.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  1140.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  1141.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  1142.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  1143.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  1144.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  1145.      > exch get 256 div
  1146.     }
  1147.    bind
  1148.         % Use correct, per-plane screens for CMYK devices only.
  1149.    //systemdict /setcolorscreen known processcolors 4 eq and
  1150.     { 3 copy 6 copy //setcolorscreen }
  1151.     { //setscreen }
  1152.    ifelse
  1153. } bind def
  1154. /.setloresscreen {    % <dpi> .setloresscreen -
  1155.   .setloreshalftone
  1156.   0 array cvx settransfer    % Genoa CET won't accept a packed array!
  1157.   /setstrokeadjust where { pop true setstrokeadjust } if
  1158. } bind def
  1159. % Use a 45-degree spot screen for high-resolution devices.
  1160. /.sethireshalftone {    % <dpi> .sethireshalftone <doscreen>
  1161.     % According to information published by Hewlett-Packard,
  1162.     % they use a 60 line screen on 300 DPI printers and
  1163.     % an 85 line screen on 600 DPI printers.
  1164.     % However, we use a 106 line screen, which produces smoother-
  1165.     % looking shades but fewer of them (32 vs. 50).
  1166.     % 46 was suggested as a good frequency value for printers
  1167.     % between 200 and 400 DPI, so we use it for lower resolutions.
  1168.     % Imagesetters need even higher frequency screens.
  1169.    //systemdict /DITHERPPI known
  1170.     { DITHERPPI
  1171.     }
  1172.     { dup cvi 100 idiv 15 .min
  1173.        {null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150}
  1174.       exch get
  1175.      }
  1176.    ifelse
  1177.    1 index 4.01 div .min    % at least a 4x4 cell
  1178.    45
  1179.     % The following screen algorithm is used by permission of the author.
  1180.     { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos 
  1181.       1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  1182.     }
  1183.    bind
  1184.     % Determine whether we have lots of process colors.
  1185.     % If so, don't bother with color screening or gamma correction.
  1186.     % Also don't do gamma correction on very high-resolution devices.
  1187.     % (This should depend on dot gain, not resolution, but we don't
  1188.     % currently have a way to determine this.)
  1189.    currentdevice mark
  1190.      /RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0
  1191.    .dicttomark .getdeviceparams
  1192.    counttomark 2 idiv 1 sub { exch pop min } repeat
  1193.    exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll
  1194.     % Stack: doscreen dpi freq angle proc
  1195.     % Ghostscript currently doesn't use correct, per-plane halftones
  1196.     % unless setcolorscreen has been executed.  Since these are
  1197.     % computationally much more expensive than binary halftones,
  1198.     % we check to make sure they are really warranted, i.e., we have
  1199.     % a high-resolution CMYK device (i.e., not a display) with
  1200.     % fewer than 5 bits per plane (i.e., not a true-color device).
  1201.    4 -1 roll 150 ge
  1202.     { /setcolorscreen where
  1203.        { pop //systemdict /COLORSCREEN known
  1204.       { COLORSCREEN }
  1205.       { 3 index }
  1206.      ifelse
  1207.      dup false ne
  1208.       { 4 1 roll 3 copy 6 copy 13 -1 roll
  1209.     % For really high-quality screening on printers, we need to
  1210.     % give each plane its own screen angle.  Unfortunately,
  1211.     % this currently has very large space and time costs.
  1212.         true eq        % true => different angles,
  1213.                 % 0 => same angles
  1214.          { { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall
  1215.          }
  1216.         if //setcolorscreen
  1217.       }
  1218.       { pop //setscreen    % false => single binary screen
  1219.       }
  1220.      ifelse
  1221.        }
  1222.        { //setscreen        % setcolorscreen not known
  1223.        }
  1224.       ifelse
  1225.     }
  1226.     { //setscreen            % not high resolution
  1227.     }
  1228.    ifelse
  1229. } bind def
  1230. /.sethiresscreen {    % <dpi> .sethiresscreen -
  1231.   .sethireshalftone
  1232.             % Stack: doscreen
  1233.     {    % Set the transfer function to lighten up the grays.
  1234.     % We correct at the high end so that very light grays
  1235.     % don't disappear completely if they darken <1 screen pixel.
  1236.     % Parameter values closer to 1 are better for devices with
  1237.     % less dot spreading; lower values are better with more spreading.
  1238.     % The value 0.8 is a compromise that will probably please no one!
  1239.     %
  1240.     % Because of a bug in FrameMaker, we have to accept operands
  1241.     % outside the valid range of [0..1].
  1242.       { dup dup 0.0 gt exch 1.0 lt and
  1243.      { 0.8 exp dup dup 0.9375 gt exch 0.999 lt and    % > 15/16
  1244.         { .currentscreenlevels 1 sub    % tweak to avoid boundary
  1245.           1 exch div 1 exch sub .min
  1246.         }
  1247.        if
  1248.      }
  1249.     if
  1250.       }
  1251.     }
  1252.     {    % Set the transfer function to the identity.
  1253.       0 array cvx        % Genoa CET won't accept a packed array!
  1254.     }
  1255.    ifelse settransfer
  1256.    /setstrokeadjust where { pop false setstrokeadjust } if
  1257.     % Increase fill adjustment so that we effectively use Adobe's
  1258.     % any-part-of-pixel rule.
  1259.    0.5 .setfilladjust
  1260. } bind def
  1261. % Set the default screen and BG/UCR.
  1262. /.setdefaultbgucr {
  1263.   systemdict /setblackgeneration known {
  1264.     { pop 0 } dup setblackgeneration setundercolorremoval
  1265.   } if
  1266. } bind def
  1267. /.useloresscreen {    % - .useloresscreen <bool>
  1268.     % Compute min(|dpi x|,|dpi y|) as the definition of the resolution.
  1269.   72 72 matrix defaultmatrix dtransform abs exch abs .min
  1270.   dup 150 lt //systemdict /DITHERPPI known not and
  1271. } bind def
  1272.  
  1273. % The following implementation uses LL2 extensions, but only in stopped
  1274. % contexts so that with LL1, the .set??reshalftone will be used.
  1275. %
  1276. %    - .getdefaulthalftone <halftonedict> true    if default found
  1277. %                  false            
  1278. /.getdefaulthalftone {
  1279.   % try the device to see if it has a default halftone
  1280.   { currentdevice /HalftoneDefault gsgetdeviceprop } stopped
  1281.   { pop pop false }        % no device property
  1282.   { dup type /dicttype eq { true } { pop false } ifelse }
  1283.   ifelse
  1284.   % stack: <halftonedict> true    if default found
  1285.   %         false          not found
  1286.   dup not
  1287.   { % device did not provide a default, try Resource
  1288.     pop { /Default /Halftone /findresource .systemvar exec } stopped 
  1289.     { pop pop false } { true } ifelse
  1290.   }
  1291.   if
  1292. } bind def
  1293.  
  1294. /.setdefaulthalftone {
  1295.   .getdefaulthalftone 
  1296.   { sethalftone }
  1297.   { % default not found
  1298.     .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse
  1299.   }
  1300.   ifelse
  1301. } bind def
  1302.  
  1303. /.setdefaultscreen {
  1304.   .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse
  1305.   .setdefaultbgucr
  1306. } bind def
  1307.  
  1308. % Load the initialization files for optional features.
  1309. %% Replace 4 INITFILES
  1310. systemdict /INITFILES known
  1311.  { INITFILES { dup runlibfile VMDEBUG } forall
  1312.  }
  1313. if
  1314.  
  1315. % If Level 2 (or higher) functionality is implemented, enable it now.
  1316. /.setlanguagelevel where {
  1317.   pop 2 .setlanguagelevel
  1318.     % If the resource machinery is loaded, fix up some things now.
  1319.   /.fixresources where { pop .fixresources } if
  1320. } if
  1321. /ll3dict where {
  1322.   pop 3 .setlanguagelevel
  1323. } if
  1324.  
  1325. (END INITFILES) VMDEBUG
  1326.  
  1327. % Create a null font.  This is the initial font.
  1328. 8 dict dup begin
  1329.   /FontMatrix [ 1 0 0 1 0 0 ] readonly def
  1330.   /FontType 3 def
  1331.   /FontName () def
  1332.   /Encoding StandardEncoding def
  1333.   /FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ...
  1334.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  1335.   /PaintType 0 def        % shouldn't be needed!
  1336. end
  1337. /NullFont exch definefont setfont
  1338.  
  1339. % Define NullFont as the font.
  1340. /NullFont currentfont def
  1341.  
  1342. % Load initial fonts from FONTPATH directories, Fontmap file,
  1343. % and/or .getccfont as appropriate.
  1344. .loadinitialfonts
  1345.  
  1346. % Remove NullFont from FontDirectory, so it can't be accessed by mistake.
  1347. /undefinefont where {
  1348.   pop /NullFont undefinefont
  1349. } {
  1350.   FontDirectory /NullFont .undef
  1351. } ifelse
  1352.  
  1353. (END FONTS) VMDEBUG
  1354.  
  1355. % Restore the real definition of runlibfile.
  1356. /runlibfile /.runlibfile load def
  1357. currentdict /.runlibfile .undef
  1358.  
  1359. % Bind all the operators defined as procedures.
  1360. /.bindoperators        % binds operators in currentdict
  1361.  { % Temporarily disable the typecheck error.
  1362.    errordict /typecheck 2 copy get
  1363.    errordict /typecheck { pop } put    % pop the command
  1364.    currentdict
  1365.     { dup type /operatortype eq
  1366.        { % This might be a real operator, so bind might cause a typecheck,
  1367.      % but we've made the error a no-op temporarily.
  1368.      .bind        % do a real bind even if NOBIND is set
  1369.        }
  1370.       if pop pop
  1371.     } forall
  1372.    put
  1373.  } def
  1374. NOBIND DELAYBIND or not { .bindoperators } if
  1375.  
  1376. % Establish a default environment.
  1377.  
  1378. defaultdevice
  1379. % The following line used to skip setting of page size and resolution if
  1380. % NODISPLAY was selected.  We think this was only to save time and memory,
  1381. % and it is a bad idea because it prevents setting the resolution in this
  1382. % situation, which pstoedit (among other programs) relies on.
  1383. %DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
  1384. systemdict /DEVICEWIDTH known
  1385. systemdict /DEVICEHEIGHT known or
  1386. systemdict /DEVICEWIDTHPOINTS known or
  1387. systemdict /DEVICEHEIGHTPOINTS known or
  1388. systemdict /DEVICEXRESOLUTION known or
  1389. systemdict /DEVICEYRESOLUTION known or
  1390. systemdict /PAPERSIZE known or
  1391. not { (%END DEVICE) .skipeof } if
  1392. % Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE.
  1393. systemdict /PAPERSIZE known
  1394. systemdict /DEVICEWIDTH known not and
  1395. systemdict /DEVICEHEIGHT known not and
  1396. systemdict /DEVICEWIDTHPOINTS known not and
  1397. systemdict /DEVICEHEIGHTPOINTS known not and
  1398.  {    % Convert the paper size to device dimensions.
  1399.    true statusdict /.pagetypenames get
  1400.     { PAPERSIZE eq
  1401.        { PAPERSIZE load
  1402.          dup 0 get /DEVICEWIDTHPOINTS exch def
  1403.          1 get /DEVICEHEIGHTPOINTS exch def
  1404.          pop false exit
  1405.        }
  1406.       if
  1407.     }
  1408.    forall
  1409.     { (Unknown paper size: ) print PAPERSIZE ==only (.) =
  1410.     }
  1411.    if
  1412.  }
  1413. if
  1414. % Adjust the device parameters per the command line.
  1415. % It is possible to specify resolution, pixel size, and page size;
  1416. % since any two of these determine the third, conflicts are possible.
  1417. % We simply pass them to .setdeviceparams and let it sort things out.
  1418.    mark /HWResolution null /HWSize null /PageSize null .dicttomark
  1419.    .getdeviceparams .dicttomark begin
  1420.    mark
  1421.     % Check for resolution.
  1422.    /DEVICEXRESOLUTION where dup
  1423.     { exch pop HWResolution 0 DEVICEXRESOLUTION put }
  1424.    if
  1425.    /DEVICEYRESOLUTION where dup
  1426.     { exch pop HWResolution 1 DEVICEYRESOLUTION put }
  1427.    if
  1428.    or { /HWResolution HWResolution } if
  1429.     % Check for device sizes specified in pixels.
  1430.    /DEVICEWIDTH where dup
  1431.     { exch pop HWSize 0 DEVICEWIDTH put }
  1432.    if
  1433.    /DEVICEHEIGHT where dup
  1434.     { exch pop HWSize 1 DEVICEHEIGHT put }
  1435.    if
  1436.    or { /HWSize HWSize } if
  1437.     % Check for device sizes specified in points.
  1438.    /DEVICEWIDTHPOINTS where dup
  1439.     { exch pop PageSize 0 DEVICEWIDTHPOINTS put }
  1440.    if
  1441.    /DEVICEHEIGHTPOINTS where dup
  1442.     { exch pop PageSize 1 DEVICEHEIGHTPOINTS put }
  1443.    if
  1444.    or { /PageSize PageSize } if
  1445.     % Check whether any parameters were set.
  1446.    dup mark eq { pop } { defaultdevice putdeviceprops } ifelse
  1447.    end
  1448. %END DEVICE
  1449. % Set any device properties defined on the command line.
  1450. % If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace.
  1451. systemdict /BufferSpace known
  1452. systemdict /MaxBitmap known not and
  1453.  { systemdict /MaxBitmap BufferSpace put
  1454.  } if
  1455. dup getdeviceprops
  1456. counttomark 2 idiv
  1457.  { systemdict 2 index known
  1458.     { pop dup load counttomark 2 roll }
  1459.     { pop pop }
  1460.    ifelse
  1461.  } repeat
  1462. counttomark dup 0 ne
  1463.  { 2 add -1 roll putdeviceprops }
  1464.  { pop pop }
  1465. ifelse
  1466. % If the initial device parameters are invalid, the setdevice may fail.
  1467. % Trap this and produce a reasonable error message.
  1468. { setdevice }        % does an erasepage
  1469. DEBUG { exec false } { .internalstopped } ifelse {
  1470.   (**** Unable to open the initial device, quitting.) = 1 .quit
  1471. } if
  1472.  
  1473. % If the media size is fixed, update the current page device dictionary.
  1474. FIXEDMEDIA
  1475. dup { pop systemdict /.currentpagedevice known } if
  1476. dup { pop .currentpagedevice exch pop } if
  1477. not { (%END MEDIA) .skipeof } if
  1478. currentpagedevice dup length dict .copydict
  1479. dup /Policies
  1480.     % Stack: <pagedevice> <pagedevice> /Policies
  1481. 1 index /InputAttributes
  1482. 2 copy get dup length dict .copydict
  1483.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1484.     %   /InputAttributes <inputattrs'>
  1485. dup 0 2 copy get dup length dict .copydict
  1486.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1487.     %   /InputAttributes <inputattrs'> <inputattrs'> 0 <attrs0'>
  1488. dup /PageSize 7 index /PageSize get
  1489. put                % PageSize in 0
  1490. put                % 0 in InputAttributes
  1491. put                % InputAttributes in pagedevice
  1492. % Also change the page size policy so we don't get an error.
  1493.     % Stack: <pagedevice> <pagedevice> /Policies
  1494. 2 copy get dup length dict .copydict
  1495.     % Stack: <pagedevice> <pagedevice> /Policies <policies'>
  1496. dup /PageSize 7 put        % PageSize in Policies
  1497. put                % Policies in pagedevice
  1498. .setpagedevice
  1499. %END MEDIA
  1500. %END DISPLAYING
  1501.  
  1502. (END DEVICE) VMDEBUG
  1503.  
  1504. % Establish a default upper limit in the character cache,
  1505. % namely, enough room for a 18-point character at the resolution
  1506. % of the default device, or for a character consuming 1% of the
  1507. % maximum cache size, whichever is larger.
  1508. mark
  1509.     % Compute limit based on character size.
  1510.   18 dup dtransform
  1511.   exch abs cvi 31 add 32 idiv 4 mul    % X raster
  1512.   exch abs cvi mul        % Y
  1513.     % Compute limit based on allocated space.
  1514.   cachestatus pop pop pop pop pop exch pop 0.01 mul cvi
  1515.   .max dup 10 idiv exch
  1516. setcacheparams
  1517. % Conditionally disable the character cache.
  1518. NOCACHE { 0 setcachelimit } if
  1519.  
  1520. (END CONFIG) VMDEBUG
  1521.  
  1522. % Initialize graphics.
  1523.  
  1524. .setdefaultscreen
  1525. initgraphics
  1526.  
  1527. % The interpreter relies on there being at least 2 entries
  1528. % on the graphics stack.  Establish the second one now.
  1529. gsave
  1530.  
  1531. % Define some control sequences as no-ops.
  1532. % This is a hack to get around problems
  1533. % in some common PostScript-generating applications.
  1534. <04> cvn { } def        % Apple job separator
  1535. <0404> cvn { } def        % two of the same
  1536. <1b> cvn { } def        % MS Windows LaserJet 4 prologue
  1537.                 % (UEL = ESC %-12345X)
  1538. <1b45> cvn { } def        % PJL reset prologue (ESC E)
  1539. <1b451b> cvn { } def        % PJL reset epilogue (ESC E + UEL)
  1540. <041b> cvn { } def        % MS Windows LaserJet 4 epilogue (^D + UEL)
  1541. (\001M) cvn            % TBCP initiator
  1542.  { currentfile /TBCPDecode filter cvx exec
  1543.  } bind def
  1544. /@PJL                % H-P job control
  1545.  { currentfile //=string readline { pop } if
  1546.  } bind def
  1547.  
  1548. % If we want a "safer" system, disable some obvious ways to cause havoc.
  1549. SAFER not { (%END SAFER) .skipeof } if
  1550.  
  1551. .currentglobal true .setglobal
  1552. /SAFETY 2 dict
  1553.   dup /safe DELAYSAFER not put
  1554.   dup /tempfiles 10 dict put
  1555. readonly def
  1556. .setglobal
  1557.  
  1558. /.setsafe
  1559.   { //SAFETY /safe //true .forceput % overrides readonly
  1560.   } .bind executeonly odef
  1561.  
  1562. /file
  1563.  { //SAFETY /safe get {
  1564.      dup (r) eq 2 index (%pipe*) .stringmatch not and
  1565.      2 index (%std*) .stringmatch or
  1566.        { file }
  1567.        { /invalidfileaccess //signalerror exec }
  1568.      ifelse
  1569.    } {
  1570.      file
  1571.    } ifelse
  1572.  } .bind executeonly odef
  1573.  
  1574. /renamefile
  1575.   { //SAFETY /safe get
  1576.       { /invalidfileaccess //signalerror exec }
  1577.       { renamefile }
  1578.     ifelse
  1579.   } .bind executeonly odef
  1580.  
  1581.  
  1582. /deletefile {
  1583.   //SAFETY /safe get {
  1584.     % Allow deleting temporary files (created/opened with .tempfile).
  1585.       //SAFETY /tempfiles get 1 index known {
  1586.     deletefile
  1587.       } {
  1588.     /invalidfileaccess //signalerror exec
  1589.       } ifelse
  1590.     } {
  1591.       deletefile
  1592.   } ifelse
  1593. } .bind executeonly odef
  1594.  
  1595. /putdeviceprops
  1596.  { //SAFETY /safe get { 
  1597.      counttomark
  1598.      dup 2 mod 0 eq { pop /rangecheck //signalerror exec } if
  1599.      3 2 3 2 roll
  1600.       { dup index /OutputFile eq  
  1601.          { -2 roll 
  1602.            dup () ne
  1603.              { /putdeviceprops load /invalidfileaccess //signalerror exec
  1604.              } if
  1605.          3 -1 roll
  1606.          }
  1607.          { pop
  1608.          }
  1609.         ifelse
  1610.       } for
  1611.      putdeviceprops
  1612.    } {
  1613.      putdeviceprops
  1614.    } ifelse
  1615.  } .bind executeonly odef
  1616.  
  1617. % If a file is opened with .tempfile with SAFER not (yet) set,
  1618. % the file can be deleted later, even if SAFER is set.
  1619. /.tempfile {
  1620.   .tempfile    % filename file
  1621.   //SAFETY /safe get not {    % DELAYSAFER, no .setsafe yet
  1622.     //SAFETY /tempfiles get 2 index true put
  1623.   } if
  1624. } .bind executeonly odef
  1625.  
  1626. currentdict /SAFETY undef
  1627.  
  1628. %END SAFER
  1629.  
  1630. % If we delayed binding, make it possible to do it later.
  1631. /.bindnow {
  1632.   //systemdict begin .bindoperators end
  1633.   % Temporarily disable the typecheck error.
  1634.   errordict /typecheck 2 copy get
  1635.   errordict /typecheck { pop } put    % pop the command
  1636.   0 1 .delaycount 1 sub { .delaybind exch get .bind pop } for
  1637.   //systemdict /.delaybind {} .forceput    % reclaim the space
  1638.   //systemdict /.bindnow .forceundef    % ditto
  1639.   put
  1640.   //systemdict /.forcedef .forceundef        % remove temptation
  1641.   //systemdict /.forceput .forceundef        % ditto
  1642.   //systemdict /.forceundef .forceundef        % ditto
  1643. } .bind odef
  1644.  
  1645. % Turn off array packing, since some PostScript code assumes that
  1646. % procedures are writable.
  1647. false setpacking
  1648.  
  1649. (END INIT) VMDEBUG
  1650.  
  1651. /.currentuserparams where {
  1652.   pop
  1653.     % Remove real user params from psuserparams.
  1654.   mark .currentuserparams counttomark 2 idiv {
  1655.     pop psuserparams exch undef
  1656.   } repeat pop
  1657.     % Update the copy of the user parameters.
  1658.   mark .currentuserparams counttomark 2 idiv {
  1659.     userparams 3 1 roll .forceput    % userparams is read-only
  1660.   } repeat pop
  1661.     % Turn on idiom recognition, if available.
  1662.   currentuserparams /IdiomRecognition known {
  1663.     /IdiomRecognition true .definepsuserparam
  1664.   } if
  1665.   psuserparams readonly pop
  1666.   systemdict /.definepsuserparam undef
  1667.     % Save a copy of userparams for use with save/restore
  1668.     % (and, if implemented, context switching).
  1669.   .currentglobal false .setglobal
  1670.      mark userparams { } forall .dicttomark readonly
  1671.      /userparams exch .forcedef        % systemdict is read-only
  1672.   .setglobal
  1673. } if
  1674. /.currentsystemparams where {
  1675.   pop
  1676.     % Remove real system params from pssystemparams.
  1677.   mark .currentsystemparams counttomark 2 idiv {
  1678.     pop pssystemparams exch .forceundef
  1679.   } repeat pop
  1680. } if
  1681.  
  1682. % Conditionally turn image interpolation on or off.
  1683. currentdict /INTERPOLATE known not { (%END INTERPOLATE) .skipeof } if
  1684.  
  1685. /.interpolate {
  1686.   dup /Interpolate .knownget not { //false } if
  1687.   /INTERPOLATE .systemvar ne {
  1688.     dup gcheck .currentglobal exch .setglobal
  1689.     exch dup length dict copy
  1690.     dup /Interpolate /INTERPOLATE .systemvar put
  1691.     exch .setglobal
  1692.   } if
  1693. } bind odef
  1694.  
  1695. /colorimage
  1696.   { /INTERPOLATE .systemvar
  1697.       { .currentglobal                    % w h bit [] {}...{} multi ncomp glob
  1698.         //false .setglobal
  1699.         9 dict begin                      % w h bit [] {}...{} multi ncomp glob
  1700.         2 index { 1 index 7 add } { 8 } ifelse
  1701.         copy gsave pop                    % preserve the arguments
  1702.         { 0 /DeviceGray 0 /DeviceRGB /DeviceCMYK }
  1703.         1 index get setcolorspace         % ... glob w h bit [] {}...{} multi ncomp
  1704.         {0 1 0 1 0 1 0 1}
  1705.         1 index 2 mul 0 exch              % ... glob w h bit [] {}...{} multi ncomp {0 1 ...} 0 2*ncomp
  1706.         getinterval /Decode exch def      % ... glob w h bit [] {}...{} multi ncomp
  1707.         exch dup                          % ... glob w h bit [] {}...{} ncomp multi multi
  1708.         /MultipleDataSources exch def     % ... glob w h bit [] {}...{} ncomp multi
  1709.         { array astore} { pop } ifelse    % ... glob w h bit [] [{}...{}]
  1710.         /DataSource exch def              % ... glob w h bit []
  1711.         /ImageMatrix exch def             % ... glob w h bit
  1712.         /BitsPerComponent exch def        % ... glob w h
  1713.         /Height exch def                  % ... glob w
  1714.         /Width exch def                   % ... glob 
  1715.         /ImageType 1 def
  1716.         /Interpolate //true def
  1717.         .setglobal currentdict end        % ... <<>>
  1718.         image grestore
  1719.         exch { 4 add } { 6 } ifelse
  1720.         { pop } repeat                    % -
  1721.       }
  1722.       { colorimage
  1723.       }
  1724.     ifelse
  1725.   } bind odef
  1726.  
  1727. /image
  1728.   { dup type /dicttype eq
  1729.       { dup /ImageType get 3 eq
  1730.           { .currentglobal //false .setglobal exch
  1731.             dup length dict copy begin .setglobal 
  1732.             /DataDict DataDict .interpolate def
  1733.             /MaskDict MaskDict .interpolate def
  1734.             currentdict end
  1735.           }
  1736.           { .interpolate 
  1737.           }
  1738.         ifelse
  1739.         image
  1740.       }
  1741.       { /INTERPOLATE .systemvar
  1742.           { .currentglobal //false .setglobal
  1743.             8 dict begin .setglobal
  1744.             /ImageType 1 def
  1745.             /DataSource 1 index def
  1746.             /ImageMatrix 2 index def
  1747.             /BitsPerComponent 3 index def
  1748.             /Decode {0 1} def
  1749.             /Height 4 index def
  1750.             /Width 5 index def
  1751.             /Interpolate //true def
  1752.             currentdict end
  1753.             gsave /DeviceGray setcolorspace image grestore
  1754.             5 { pop } repeat
  1755.           }
  1756.           { image
  1757.           }
  1758.         ifelse
  1759.       }
  1760.     ifelse
  1761.   } bind odef
  1762.  
  1763. /imagemask {
  1764.   dup type /dicttype eq {
  1765.     .interpolate imagemask
  1766.   } {
  1767.     /INTERPOLATE .systemvar {
  1768.       .currentglobal //false .setglobal
  1769.       8 dict begin .setglobal
  1770.       /ImageType 1 def
  1771.       /DataSource 1 index def
  1772.       /ImageMatrix 2 index def
  1773.       /BitsPerComponent 1 def
  1774.       2 index { {1 0} } { {0 1} } ifelse /Decode exch def
  1775.       /Height 4 index def
  1776.       /Width 5 index def
  1777.       /Interpolate //true def
  1778.       currentdict end imagemask 5 { pop } repeat
  1779.     } {
  1780.       imagemask
  1781.     } ifelse
  1782.   } ifelse
  1783. } bind odef
  1784.  
  1785. currentdict /.interpolate undef
  1786.  
  1787. %END INTERPOLATE
  1788.  
  1789. % Establish local VM as the default.
  1790. false /setglobal where { pop setglobal } { .setglobal } ifelse
  1791. $error /.nosetlocal false put
  1792.  
  1793. (END GLOBAL) VMDEBUG
  1794.  
  1795. /.savelocalstate where {
  1796.     % If we might create new contexts, save away copies of all dictionaries
  1797.     % referenced from systemdict that are stored in local VM,
  1798.     % and also save a copy of the initial gstate.
  1799.   pop .savelocalstate
  1800. } {
  1801.     % If we're *not* running in a multi-context system and FAKEFONTS is
  1802.     % defined, add the fake fonts to LocalFontDirectory.
  1803.   .definefakefonts    % current VM is local
  1804. } ifelse
  1805.  
  1806. % Remove systemdict entries for things that have been bound in where used
  1807. % and that shouldn't be accessible by name, and close up systemdict.
  1808. currentdict /filterdict .undef
  1809. currentdict /.cidfonttypes .undef
  1810. currentdict /.colorrenderingtypes .undef
  1811. currentdict /.formtypes .undef
  1812. currentdict /.halftonetypes .undef
  1813. currentdict /.imagetypes .undef
  1814. currentdict /.imagemasktypes .undef
  1815. currentdict /.patterntypes .undef
  1816. currentdict /.shadingtypes .undef
  1817. currentdict /.wheredict .undef
  1818. end
  1819.  
  1820. % Clean up VM, and enable GC.
  1821. /vmreclaim where
  1822.  { pop NOGC not { 2 vmreclaim 0 vmreclaim } if
  1823.  } if
  1824. DELAYBIND not {
  1825.   systemdict /.forcedef .undef        % remove temptation
  1826.   systemdict /.forceput .undef        % ditto
  1827.   systemdict /.forceundef .undef    % ditto
  1828. } if
  1829. WRITESYSTEMDICT not { systemdict readonly pop } if
  1830.  
  1831. (END GC) VMDEBUG
  1832.  
  1833. % The Adobe AGM_Core used by Illustrator 9 has some code that breaks
  1834. % if the 'product' is not (Adobe PostScript Parser). A bug has been
  1835. % submitted to Adobe since this also fails with Acrobat Distiller.
  1836. % As a temporary work around, the following HACK will work for
  1837. % devices without spot color support. Once Ghostscript can
  1838. % support DeviceN and spot color separations this will need to
  1839. % be 'true' in some cases.
  1840. userdict /AGM_preserve_spots false put
  1841.  
  1842. % The interpreter will run the initial procedure (start).
  1843.